<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        var arr = ['red','green','blue'];
        console.log(arr.length);
        arr.length = 5;//把数据长度修改了5 里面应该有5个元素
        // console.log(arr);
        // console.log(arr[3]);
        // console.log(arr[4]);

        //2.新增数组元素,修改索引号
        var arr1 = ['red','green','blue'];
        arr1[3] = 'pink';
        console.log(arr1);
        arr1[0] = 'yellow';//替换原来数组元素
        arr1 = '有点意思';
        console.log(arr1);//不要直接给数组名赋值 否则里面的元素都没有了
    </script>
</head>
<body>

</body>
</html>